<template>
  <div class="container">
    <el-dialog
      title="预览文章"
      :visible.sync="dialogVisible"
      :before-close="handleClose"
    >
      <div class="dialogBody">
        <div class="title">
          <h2>{{ previeContent.title }}</h2>
          <span> {{ previeContent.createTime }} </span>
          <span>{{ previeContent.username }}</span>
          <span><i class="el-icon-view" /> {{ previeContent.visits }}</span>
        </div>
        <div v-html="previeContent.articleBody" class="content"></div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    previeContent: {
      type: Object,
      default: null
    },
    flag: {
      type: Boolean,
      default: false
    }
  },
  watch: {
    flag (newval) {
      //
      this.dialogVisible = newval
    }
  },
  data () {
    return {
      dialogVisible: false
    }
  },
  methods: {
    handleClose (done) {
      done()
      this.dialogVisible = false
      this.$emit('confirmPreview')
    },
    open () {
      this.dialogVisible = true
    },
    // 关闭
    close () {
      this.dialogVisible = false
      //
      this.$emit('confirmPreview')
    }
  }
}
</script>

<style scoped lang="scss">
.dialogBody {
  padding: 0;
  margin: 0;
  .title {
    padding-bottom: 10px;

    span {
      margin-left: 10px;
    }
  }
  .content {
    background: #f5f5f5;
    padding: 10px;
    img{
      width: 100% !important;
    }
  }
}
</style>
